package sokoban;

public class Dir {
	public final static Dir
	UP = new Dir(0, -1),
	DOWN = new Dir(0, 1),
	LEFT = new Dir(-1, 0),
	RIGHT = new Dir(1, 0);
	public final static Dir[] directions = {UP, DOWN, LEFT, RIGHT};
	public final int dx, dy;
	public char getSymb(){
		if(this==LEFT){
			return 'l';
		}
		else if(this==RIGHT){
			return 'r';
		}
		else if(this==UP){
			return 'u';
		}
		else if(this==DOWN){
			return 'd';
		}
		else{ 
			return ' ';
		}		
	}
	public static Dir getDir(char dir){
		if(dir=='l'||dir=='L'){
			return LEFT;
		}
		else if(dir=='r'||dir=='R'){
			return RIGHT;
		}
		else if(dir=='u'||dir=='U'){
			return UP;
		}
		else if(dir=='d'||dir=='D'){
			return DOWN;
		}
		else{ 
			return null;
		}
		
	}
	private Dir(int dx, int dy) {
		this.dx = dx;
		this.dy = dy;
	}
	public Dir invertDir(){
		if(this==DOWN){
			return UP;
		}
		else if(this==Dir.UP){
			return DOWN;
		}
		else if(this==Dir.LEFT){
			return RIGHT;
		}
		else if(this==Dir.RIGHT){
			return LEFT;
		}
		else{
			return null;
		}
	}
}
